import userStore from '@/store/user'
// 本地请求服务器地址
export const baseURL = 'xxxx'
// 全局请求封装
export default (options = {}) => {
	const {
		url,
		method,
		data,
		header
	} = options;
	console.log('请求信息：', data)
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseURL + url,
			method: method,
			header: {
				'content-type': 'application/json',
				'Authorization': userStore().token || '',
				...header
			},
			data: data,
			success(res) {
				console.log('响应成功：', res.data)
				resolve(res.data);
			},
			fail(err) {
				console.log('响应失败：', err)
				reject(err);
			},
			complete() {
				uni.hideLoading();
			}
		});
	});
};